package flexUnitTests
{
	import flash.filesystem.File;
	
	import flexunit.framework.Assert;
	
	import org.flexunit.assertThat;
	import org.flexunit.asserts.assertEquals;
	
	import vivek.project.pocketmoney.admin.model.AdminDataCache;
	import vivek.project.pocketmoney.admin.model.AdminDataModel;
	import vivek.project.pocketmoney.common.CommonData;
	import vivek.project.pocketmoney.common.PocketMoneyInit;
	import vivek.project.pocketmoney.common.renderer.UserListComboBoxRenderer;
	import vivek.project.pocketmoney.common.utils.CommonUtils;
	import vivek.project.pocketmoney.expenses.model.ExpenseDataModel;
	
	public class InitTests
	{		
		
		[Before]
		public function setUp():void
		{
		}
		
		[After]
		public function tearDown():void
		{
		}
		
		[BeforeClass]
		public static function setUpBeforeClass():void
		{
			var file:File=File.applicationStorageDirectory;
			file=file.resolvePath("pm.dat");
			var controlfile:File=File.applicationStorageDirectory;
			var controlfile=controlfile.resolvePath("Preferences/version.txt");
			if (file.exists){
				
					file.deleteFile();
					controlfile.deleteFile();
				}
			trace(file.nativePath);	
			new PocketMoneyInit();
		}
		
		[AfterClass]
		public static function tearDownAfterClass():void
		{
		}
		
		[Test]
		public function backupTest():void
		{
		    CommonUtils.backupData();
			var pmfile:File=File.applicationStorageDirectory;
			var dateString:String;
			dateString=CommonData.getDateFormatter().format(new Date());
			var newLocation:File=File.applicationStorageDirectory.resolvePath("pm_back_"+dateString+".dat");
			pmfile=pmfile.resolvePath("pm.dat");
			assertEquals(pmfile.size,newLocation.size);
			assertEquals(pmfile.data,newLocation.data);
		}
		private var adminDataModel:AdminDataModel=AdminDataModel.getInstance();
		[Test]
		public function loadSeedDataTest():void
		{
			Assert.assertEquals(AdminDataCache.accountData.length,15);
			Assert.assertEquals(AdminDataCache.userData.length,0);
			Assert.assertEquals(AdminDataCache.ACCOUNT_IN_USE,1);
			
		}
	}
}